#else
import System.Process (createPipeFd)
#endif
+import GHC.IO.Encoding (getLocaleEncoding)
multicastReceiveEnv :: String
multicastReceiveEnv = "GIT_ANNEX_MULTICAST_RECEIVE"
(rfd, wfd) <- createPipeFd
#endif
rh <- fdToHandle rfd
+ getLocaleEncoding >>= hSetEncoding rh
environ <- addEntry multicastReceiveEnv (show wfd) <$> getEnvironment
return (gitannex, environ, rh)
runMulticastReceive ("-I":_sessionid:fs) hs = case readish hs of
Just fd -> do
h <- fdToHandle fd
+ getLocaleEncoding >>= hSetEncoding h
mapM_ (hPutStrLn h) fs
hClose h
Nothing -> return ()
#ifdef mingw32_HOST_OS
import Utility.Env
import System.Environment (getArgs)
+#else
+import GHC.IO.Encoding (getLocaleEncoding)
#endif
import qualified Utility.Debug as Debug
let logfd = handleToFd =<< openLog (fromOsPath logfile)
if foreground
then do
- origout <- liftIO $ catchMaybeIO $
- fdToHandle =<< dup stdOutput
- origerr <- liftIO $ catchMaybeIO $
- fdToHandle =<< dup stdError
+ enc <- liftIO getLocaleEncoding
+ origout <- liftIO $ catchMaybeIO $ do
+ h <- fdToHandle =<< dup stdOutput
+ hSetEncoding h enc
+ return h
+ origerr <- liftIO $ catchMaybeIO $ do
+ h <- fdToHandle =<< dup stdError
+ hSetEncoding h enc
+ return h
let undaemonize = Utility.Daemon.foreground logfd (Just pidfile)
start undaemonize $
case startbrowser of
import System.Posix.IO.ByteString
import System.Posix.Files.ByteString
import System.Posix.Process
+import GHC.IO.Encoding (getLocaleEncoding)
import Control.Monad
import Control.Monad.IO.Class (liftIO, MonadIO)
import Data.Maybe
(Just $ combineModes readModes)
(defaultFileFlags { exclusive = True })
(CloseOnExecFlag True)
- fdToHandle fd
+ h <- fdToHandle fd
+ getLocaleEncoding >>= hSetEncoding h
+ return h
let cleanup = hClose
let go h = F.readFileString src >>= hPutStr h
bracket setup cleanup go
#ifndef mingw32_HOST_OS
import Control.Exception
import qualified System.Posix.IO
+import GHC.IO.Encoding (getLocaleEncoding)
#else
import Control.Applicative
#endif
System.Posix.IO.setFdOption writef System.Posix.IO.CloseOnExec True
readh <- System.Posix.IO.fdToHandle readf
writeh <- System.Posix.IO.fdToHandle writef
+ enc <- getLocaleEncoding
+ hSetEncoding readh enc
+ hSetEncoding writeh enc
return (readh, writeh)
let cleanup (readh, writeh) = do
hClose readh